package cn.dazhou.emergency_video

import org.springframework.web.bind.annotation.RestController
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.GetMapping

@RestController
@RequestMapping("/demo")
class MainController(private val userRepository: UserRepository) {
    @GetMapping("/add")
    fun addNewUser(name: String?, email: String?): String {
        val n = User()
        n.name = name
        n.email = email
        userRepository.save(n)
        return "Saved"
    }

    @get:GetMapping("/all")
    val allUsers: Iterable<User?>
        get() = userRepository.findAll()
}